package org.crazyit.cloud;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;

@Service
public class MemberService {
	
	@Autowired
	private RestTemplate restTpl;
	
	@HystrixCommand(fallbackMethod="getMemberFallback",groupKey="memberGroup",
			commandKey="MemberCommandKey",
			commandProperties= {
				
			},threadPoolProperties= {
					
			})
	public Member getMember(Integer id) {
		Member member = restTpl.getForObject("http://spring-hy-member/member/{id}", 
				Member.class,id);
		return member;
	}
	
	public Member getMemberFallback(Integer id) {
		Member m = new Member();
		m.setId(id);
		m.setName("error member");
		return m;
	}
	
	
}






























